package com.cloudkinto.bo.order;

import com.cloudkinto.bo.common.BaseQueryBo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang.StringUtils;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Date;

/**
 * @author long
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class OrderShopifyQueryBo extends BaseQueryBo {

    @ApiModelProperty("店铺id")
    private String shopId;

    @ApiModelProperty("店铺名")
    private String shippingName;

    @ApiModelProperty("订单名称")
    private String orderName;

    @ApiModelProperty("是否配送")
    private String isSendOut;

    @ApiModelProperty("发送状态")
    private String sendState;

    @ApiModelProperty("支付状态")
    private String payState;

    @ApiModelProperty("开始时间")
    private String startDate;

    @ApiModelProperty("结束时间")
    private String endDate;

    public Date getStartDate() {
        if (StringUtils.isBlank(startDate)) {
            return null;
        }
        DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        LocalDateTime dateTime = LocalDate.parse(startDate, format).atTime(0,0,0);
        return Date.from(dateTime.atZone(ZoneId.systemDefault()).toInstant());
    }
    public Date getEndDate() {
        if (StringUtils.isBlank(endDate)) {
            return null;
        }
        DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        LocalDateTime dateTime = LocalDate.parse(endDate, format).atTime(23,59,59);
        return Date.from(dateTime.atZone(ZoneId.systemDefault()).toInstant());
    }

//    @ApiModelProperty("转运")
//    private String fulfillmentChannel;
}
